<?php

require_once('HTTP/Client.php');

$params=array();
$params['proxy_host'] = 'xxx.xxx.xxx.xxx';
$params['proxy_port'] = 3128; 

$headers=array( "User-Agent" => "Mozilla Firefox/3.6.6");
$client= new HTTP_Client( $params, $headers );
$client->setMaxRedirects(5);


$client->enableHistory(false); 

$reponse='';
$ret= $client->get($argv[1], $reponse);

echo "Code HTTP: $ret\n";

if ($ret == 200) {
	$rep=$client->currentResponse();
	
	if ( isset($argv[2]) ) {
		file_put_contents($argv[2], $rep['body']);
	} else {
		print_r($rep);
	}
} else {
 	echo "Erreur requete HTTP\n";
}
?>
